import { Component } from '@angular/core';
import { OnInit } from '@angular/core';
import {HttpClient} from "@angular/common/http";

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit{

  constructor(private http:HttpClient){}
  private show: boolean = false;
  public opened: boolean = false;
  private openChat: boolean = true;
  title: string;
  attentions:any;
  ngOnInit(): void {
    this.title = 'Family Trip';

    console.log(this.openChat);
  }
  public onToggle(): void {
    this.show = !this.show;
    this.getMessage();

  }

  private getMessage(){
    this.http.get('mock-data/attention.json').subscribe(
      data=>{
        this.attentions = data['results'];
      }
    )
  }

  private match(){
    let status;
    this.http.get('mock-data/attention.json').subscribe(
      data=>{
        status = data['status'];
        if(status == 'ok'){
          this.opened = false;
        }
      }
    )
  }
  close(type:string){
    if(type == 'cancel'){
      this.opened = true;
    }else if(type =='yes'){
      this.openChat = false;
      this.opened = true;
    }

  }
}
